﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sripirom.ATS.Core.ExceptionHandler
{                                   
    public class ExceptionGeneric : System.Exception
    {

        #region public String Code

        private String _code = String.Empty;
        /// <summary>
        /// Gets or sets the exception code.
        /// </summary>
        public String Code
        {
            get
            {
                return _code;
            }
            set
            {
                _code = value;
            }
        }

        #endregion
        #region public String Description

        private String _description;
        /// <summary>
        /// Gets or sets the exception description.
        /// </summary>
        public String Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        #endregion
        #region public ResponseCode ResponseCode

        private String _responseCode = String.Empty;
        /// <summary>
        /// Gets or sets the stand code which be used as an identification for the exception.
        /// </summary>
        public String ResponseCode
        {
            get
            {
                return _responseCode;
            }
            set
            {
                _responseCode = value;
            }
        }

        #endregion
        #region public String Solution

        private String _solution;
        /// <summary>
        /// Gets or sets the solution used to solve this exception.
        /// </summary>
        public String Solution
        {
            get
            {
                return _solution;
            }
            set
            {
                _solution = value;
            }
        }

        #endregion

        public ExceptionGeneric()
            : base()
        {
        }

        public ExceptionGeneric(string message)
            : base(message)
        {
        }

        public ExceptionGeneric(string message, System.Exception innerException)
            : base(message, innerException)
        {
        }

        public ExceptionGeneric(string message, System.Data.SqlClient.SqlException innerException)
            : base(message, innerException)
        {
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override string ToString()
        {
            StringBuilder _str = new StringBuilder()
              .Append("Found error exception ").Append(this.GetType()).Append("\n")
              .Append("Message [").Append(this.Message).Append("]\n")
              .Append("Code [").Append(this.Code).Append("]\n")
              .Append("Description [").Append(this.Description).Append("]\n")
              .Append("Solution [").Append(this.Solution).Append("]\n");

            System.Exception _inner = InnerException;
            while (_inner != null)
            {
                _str.Append(_inner.StackTrace).Append("\n");
                _inner = _inner.InnerException;
            }

            return _str.ToString();
        }
    }
}
